package cn.shop.crontab;

import com.aliyun.openservices.ons.api.bean.ProducerBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author : 李一涵
 * @date : Created in 2022/5/28 15:03
 * @description :
 */
@Configuration
@ConditionalOnExpression("'${spring.profiles.active:dev}' == 'online'")
public class ProducerUtil {
    @Resource
    private AliyunMQConfig aliyunMQConfig;

    @Bean(initMethod = "start", destroyMethod = "shutdown")
    public ProducerBean buildProducer() {
        ProducerBean producer = new ProducerBean();
        producer.setProperties(aliyunMQConfig.getMqProperties());
        return producer;
    }
}
